package flc.ast.fragment;

import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.chad.library.adapter.base.BaseQuickAdapter;

import java.util.ArrayList;
import java.util.List;

import flc.ast.R;
import flc.ast.activity.FormatRecordActivity;
import flc.ast.activity.SelImportVideoActivity;
import flc.ast.adapter.ImageAdapter;
import flc.ast.databinding.FragmentConvertBinding;
import stark.common.basic.base.BaseNoModelFragment;
import stark.common.basic.event.EventStatProxy;
import stark.common.basic.utils.FastClickUtil;

/**
 * A simple {@link Fragment} subclass.
 * Use the {@link ConvertFragment#newInstance} factory method to
 * create an instance of this fragment.
 */
public class ConvertFragment extends BaseNoModelFragment<FragmentConvertBinding> {

    private ImageAdapter imageAdapter;

    @Override
    protected int onCreate() {
        return R.layout.fragment_convert;
    }

    @Override
    protected void initView() {
        EventStatProxy.getInstance().statEvent1(getActivity(), mDataBinding.event1Container);
        EventStatProxy.getInstance().statEvent5(getActivity(), mDataBinding.event5Container);
        mDataBinding.rvImgList.setLayoutManager(new LinearLayoutManager(mContext,LinearLayoutManager.HORIZONTAL,false));
        imageAdapter=new ImageAdapter();
        mDataBinding.rvImgList.setAdapter(imageAdapter);
        imageAdapter.setOnItemClickListener(this);
        mDataBinding.rlConvertRecord.setOnClickListener(this);
    }

    @Override
    protected void onClickCallback(View v) {
        if (FastClickUtil.isFastClick()) return;
        switch (v.getId()){
            case R.id.rlConvertRecord:
                startActivity(FormatRecordActivity.class);
                break;
        }
    }

    @Override
    protected void onItemClickCallback(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {
        SelImportVideoActivity.type=0;
        startActivity(SelImportVideoActivity.class);
    }

    @Override
    protected void initData() {
        List<Integer> list=new ArrayList<>();
        list.add(R.drawable.mkv);
        list.add(R.drawable.mp4);
        list.add(R.drawable.avi);
        list.add(R.drawable.gp3);
        list.add(R.drawable.mov1);
        imageAdapter.setList(list);
    }
}